/*
 * hd44780-4r.c
 * Implements 4bit read operations
 *
 *  Created on: Oct 5, 2009
 *      Author: Orlando Arias
 *	   License: GPLv3
 *
 *   libhd44780 for Arduino systems
 *   Copyright (C) 2009  Orlando Arias
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "WProgram.h"
#include "private-4.h"

#include "hd44780-4.h"

/*
 *  Return values of *_getRaw() functions are in the form
 *  BF AC AC AC AC AC AC AC or D A T A B I T S
 *  depending on the value given to Register Select
 */
uint8_t lcd4_getAC(LCD4 *l){
	/*
	 *  RS = 0
	 *  Bitwise ANDing with 0x7F (01111111) to return
	 *  address counter
	 */
	return lcd4_getRaw(l, LOW) & 0x7F;
}

uint8_t lcd4_getDDRAM(LCD4 *l){
	/*
	 *  RS = 1
	 *  Read DDRAM location
	 */
	return lcd4_getRaw(l, HIGH);
}

uint8_t lcd4_getState(LCD4 *l){
	/*
	 *  RS = 0
	 *  Bitshift so that MSB becomes only available bit to
	 *  return busy flag status.
	 */
	return lcd4_getRaw(l, LOW) >> 7;
}
